{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "50228173",
   "metadata": {},
   "source": [
    "# 人脸库管理 API 组\n",
    "1 创建FaceSet  \n",
    "2 查询FaceSet  \n",
    "3 存入face_token数据  \n",
    "4 获取FaceSet信息数据  \n",
    "5 人脸搜索  \n",
    "6 人脸对比  "
   ]
  },
  {
   "cell_type": "markdown",
   "id": "affc2b29",
   "metadata": {},
   "source": [
    "## 创建Face\n",
    "- 描述\n",
    "> 创建一个人脸的集合 FaceSet，用于存储人脸标识 face_token。一个 FaceSet 能够存储10000个 face_token。      \n",
    "> 试用API Key可以创建1000个FaceSet，正式API Key可以创建10000个FaceSet。    \n",
    "- 调用URL\n",
    "> https://api-cn.faceplusplus.com/facepp/v3/faceset/create\n",
    "- 调用方法\n",
    "> POST\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "5956fe29",
   "metadata": {},
   "outputs": [],
   "source": [
    "import requests\n",
    "\n",
    "FaceSet_url = 'https://api-cn.faceplusplus.com/facepp/v3/faceset/create'\n",
    "API_Key = \"Vf1TVr0kb7C0wavMhpaKym9OSkwGRNaw\"\n",
    "API_Secret = \"POyLi052sYdsVnEe-Gs27AxP9fqd7zHJ\"\n",
    "\n",
    "payload = {\n",
    "    \"api_key\":API_Key,\n",
    "    \"api_secret\":API_Secret\n",
    "}\n",
    "\n",
    "r = requests.post(url=FaceSet_url,params=payload)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "21ab97ab",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Response [200]>"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "ad5c44c8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'faceset_token': 'b5e4f35146c129b4f3d6d7e750315611',\n",
       " 'time_used': 152,\n",
       " 'face_count': 0,\n",
       " 'face_added': 0,\n",
       " 'request_id': '1648468838,a889fae5-80af-4cc6-ad3d-9463c035f830',\n",
       " 'outer_id': '',\n",
       " 'failure_detail': []}"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r.json()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "fc5830c0",
   "metadata": {},
   "outputs": [],
   "source": [
    "FaceSet_getfacesets_url = 'https://api-cn.faceplusplus.com/facepp/v3/faceset/getfacesets'\n",
    "API_Key = \"Vf1TVr0kb7C0wavMhpaKym9OSkwGRNaw\"\n",
    "API_Secret = \"POyLi052sYdsVnEe-Gs27AxP9fqd7zHJ\"\n",
    "\n",
    "payload = {\n",
    "    \"api_key\":API_Key,\n",
    "    \"api_secret\":API_Secret\n",
    "}\n",
    "\n",
    "r = requests.post(url=FaceSet_getfacesets_url,params=payload)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "05f07866",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Response [200]>"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "12831c08",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'time_used': 97,\n",
       " 'facesets': [{'faceset_token': '6aaaa11184769846b83e74b6cdd71977',\n",
       "   'outer_id': '',\n",
       "   'display_name': '测试的人脸库',\n",
       "   'tags': ''},\n",
       "  {'faceset_token': 'b0f2585396b82123689c9d55c10430fc',\n",
       "   'outer_id': '',\n",
       "   'display_name': '',\n",
       "   'tags': ''},\n",
       "  {'faceset_token': 'ecbe1fc663cc157c8084c8b50a566542',\n",
       "   'outer_id': '',\n",
       "   'display_name': '测试的人脸库',\n",
       "   'tags': ''},\n",
       "  {'faceset_token': 'ebffac65b13122b260ff2977dff65fdb',\n",
       "   'outer_id': '',\n",
       "   'display_name': '测试的人脸库',\n",
       "   'tags': ''},\n",
       "  {'faceset_token': '8df353cff4241563dd9b9d11524bfae2',\n",
       "   'outer_id': '',\n",
       "   'display_name': '测试的人脸库',\n",
       "   'tags': ''},\n",
       "  {'faceset_token': '8ffd4e7596545c462e9c41d3668431f8',\n",
       "   'outer_id': '',\n",
       "   'display_name': '测试的人脸库',\n",
       "   'tags': ''},\n",
       "  {'faceset_token': '4418d33513d0ee7e9ff2a65ebc35b6b8',\n",
       "   'outer_id': '',\n",
       "   'display_name': '测试的人脸库',\n",
       "   'tags': ''},\n",
       "  {'faceset_token': 'b5e4f35146c129b4f3d6d7e750315611',\n",
       "   'outer_id': '',\n",
       "   'display_name': '',\n",
       "   'tags': ''}],\n",
       " 'request_id': '1648468973,823fcf3f-a6a6-4f87-8367-4b8b14bdb92e'}"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r.json()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "8d606e1b",
   "metadata": {},
   "outputs": [],
   "source": [
    "FaceSet_getfacesets_url = 'https://api-cn.faceplusplus.com/facepp/v3/faceset/update'\n",
    "API_Key = \"Vf1TVr0kb7C0wavMhpaKym9OSkwGRNaw\"\n",
    "API_Secret = \"POyLi052sYdsVnEe-Gs27AxP9fqd7zHJ\"\n",
    "\n",
    "payload = {\n",
    "    \"api_key\":API_Key,\n",
    "    \"api_secret\":API_Secret\n",
    "}\n",
    "\n",
    "r = requests.post(url=FaceSet_getfacesets_url,params=payload)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5ec7b517",
   "metadata": {},
   "outputs": [],
   "source": [
    "FaceSet_update_url = 'https://api-cn.faceplusplus.com/facepp/v3/faceset/getdetail'\n",
    "API_Key = \"Vf1TVr0kb7C0wavMhpaKym9OSkwGRNaw\"\n",
    "API_Secret = \"POyLi052sYdsVnEe-Gs27AxP9fqd7zHJ\"\n",
    "\n",
    "payload = {\n",
    "    \"api_key\":API_Key,\n",
    "    \"api_secret\":API_Secret,\n",
    "    \"user_data\"\n",
    "}\n",
    "\n",
    "r = requests.post(url=FaceSet_update_url,params=payload)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
